/*   Shotscreens
 *   Copyright (C) 2010, Vadim Zakondyrin (http://crystalnix.com)
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef QGRAPHICSARROWITEM_H
#define QGRAPHICSARROWITEM_H

#include <QGraphicsItemGroup>
#include <QPen>

class QGraphicsArrowItem : public QGraphicsItemGroup
{
public:
    QGraphicsArrowItem(const QPen & pen = QPen(), QGraphicsItem *parent = 0);
    QGraphicsArrowItem(const QLineF & line,
                       const QPen & pen = QPen(), QGraphicsItem *parent = 0);
    QGraphicsArrowItem(qreal x1, qreal y1, qreal x2, qreal y2,
                       const QPen & pen = QPen(), QGraphicsItem *parent = 0);

    ~QGraphicsArrowItem();

    void setPen(const QPen & pen);
    inline QPen pen() { return mainLine->pen(); }

    void setLine(const QLineF & line);
    inline void setLine(qreal x1, qreal y1, qreal x2, qreal y2) { setLine(QLineF(x1, y1, x2, y2)); }
    inline QLineF line() { return mainLine->line(); }

    virtual QRectF boundingRect() const;
    void updateBoundingRectByRect(QRectF &rect, const QRectF &anotherRect) const;
private:
    QGraphicsLineItem * mainLine;
    QGraphicsLineItem * leftLine;
    QGraphicsLineItem * rightLine;
    void initializeArrow(const QPen & pen);
};

#endif // QGRAPHICSARROWITEM_H
